package de.thw.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import de.thw.web.factory.FormFactory;
import de.thw.web.factory.MainFactory;
import de.thw.web.factory.PageFactory;
import de.thw.web.model.User;
import de.thw.web.object.Form;
import de.thw.web.object.Page;

@Controller
@RequestMapping("/user/")
public class UserController {

	@RequestMapping("create")
	public ModelAndView create(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		User user = new User();

		user.setFirstname("Marvin");
		user.setLastname("Naumann");
		user.setName("marvin.naumann");
		user.setEmail("marvin.naumann@.de");

		Page page = PageFactory.getCurrentPage();
		Form form = FormFactory.getForm(user);
		ModelAndView modelView = MainFactory.getModelAndView(page);

		modelView.addObject("form", form);

		return modelView;
	};

};